Eddie's Lessons, version 2

level: beginner

by Alyce Watson [http://alycesrestaurant.com/]

Home

Tip Corner

API Corner

Youth Corner

SpriteByte: Basics

StyleBits 3

Shaped Window

Recursion

Eddie's Lessons

Beginners Programming

Help

Index


What is Eddie?

Eddie is a new code editor written in Liberty BASIC, for Liberty BASIC. Eddie can be customized and extended to meet the needs of the individual programmer. The newest version is available here: Eddie!

Eddie's Lessons This Month:


Modularity

If you remember the first installment of Eddie on program design, we mentioned that we want to keep the code modular. To that end, we're now going to set up variable names at the top of the code to make things easier as we add to Eddie. This version of Eddie introduces an ini file of user information. We're setting the IniFile$ name at the top of the code. In the future, if we change the name of the ini file, we only need to change it in one place - at the top of the code. Every other time we use this filename in the code, we'll use the variable IniFile$.

IniFile$ = "eddie2.ini"

We'll also set up some other variables at the top of the code. When it is time to add to Eddie, or to modify Eddie, we can easily drop in a new routine that uses these variables.

[VariableSetup]
    '#f will be the handle for opening files
    'note that Version$ is a reserved variable name
    EddieVersion$ = "2"
    'path to Liberty.exe for running programs:
    LibertyExe$ = ""
    'name of ini file for this version of Eddie
    IniFile$ = "eddie2.ini"
    'variable to hold contents of texteditor
    text$ = ""
    'filename for writing a temp file to disk
    tempfile$ = DefaultDir$ + "\tempfile.bas"
    'filename for user saving file to disk
    savefile$ = ""

Descriptive Names

Did you notice the names we gave to the variables? The variable that holds the version of Eddie is called EddieVersion$. We could have shortened it to save on typing. Why not just call it E$? It's pretty clear from the name that EddieVersion$ holds the version of Eddie. If a new programmer looks at that variable name, he'll understand its use right away. We'll recognize it, too, when we modfiy Eddie in the future. It's a very good idea to use descriptive variable names in code.

Branch Labels, Too!

Liberty BASIC allows us to use line numbers as branch labels. It's perfectly acceptable to have this code:

    goto 110 

What's at line 110, though? If we use something like this:

    goto [openFile]

it's pretty clear what we'll find at that branch of code! Using short variable names and branch names saves on typing, but it doesn't make for readable code! Use descriptive names! You'll be glad you did!


Home

Tip Corner

API Corner

Youth Corner

SpriteByte: Basics

StyleBits 3

Shaped Window

Recursion

Eddie's Lessons

Beginners Programming

Help

Index